package com.colorfruit.framework.model.sys;

import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;

import java.util.Map;

/**
 * 业务描述：
 *
 * @Auther: chenjiayuan
 * @Date: create in 2018/7/6 14
 * @Description:
 */
@Data
@NoArgsConstructor
@Slf4j
public class ValidationResult {
    private Boolean hasErrors;
    private Map<String,String> errorMsg;

    public ValidationResult(Boolean hasErrors, Map<String, String> errorMsg) {
        this.hasErrors = hasErrors;
        this.errorMsg = errorMsg;
    }

    public String toMsgString(){
        StringBuilder errorMsgBuilder = new StringBuilder("");
        errorMsg.forEach((k,v)->errorMsgBuilder.append(",").append(k).append(v));
        return errorMsgBuilder.substring(1);
    }
}
